package ve.ejb.metadata;

import ve.ejb.entity.*;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author memozac
 */
@Entity
public class Dimension implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long idDimension;

    @ManyToMany(targetEntity=ScoreCard.class) @JoinTable(name="ScoreCardDimension", joinColumns=@JoinColumn(name="idDimension"),
    inverseJoinColumns=@JoinColumn(name="idScoreCard")) private Collection<ScoreCard> scoreCards;

    @OneToMany private List<DimensionMember> dimensionMembers;

    @Column(columnDefinition="text") private String name;

    @Temporal(value = TemporalType.TIMESTAMP) private Date registerDate;

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    public List<DimensionMember> getDimensionMembers() {
        return dimensionMembers;
    }

    public void setDimensionMembers(List<DimensionMember> dimensionMembers) {
        this.dimensionMembers = dimensionMembers;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getIdDimension() {
        return idDimension;
    }

    public void setIdDimension(Long idDimension) {
        this.idDimension = idDimension;
    }

    public Collection<ScoreCard> getScoreCards() {
        return scoreCards;
    }

    public void setScoreCards(Collection<ScoreCard> scoreCards) {
        this.scoreCards = scoreCards;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDimension != null ? idDimension.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Dimension)) {
            return false;
        }
        Dimension other = (Dimension) object;
        if ((this.idDimension == null && other.idDimension != null) || (this.idDimension != null && !this.idDimension.equals(other.idDimension))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ve.ejb.entity.Dimension[id=" + idDimension + "]";
    }

}//ends of class
